//把个人信息存放在pinia中
import { defineStore } from 'pinia'
import { ref, computed } from 'vue'

const useUserInfoStore = defineStore('userInfo', () => {
  //定义状态相关的内容
  const info = ref({})

  const isLogin = computed(() => Object.keys(info.value).length > 0)

  const setInfo = (newInfo) => {
    info.value = newInfo
  }

  const removeInfo = () => {
    info.value = {}
  }

  return { info, setInfo, removeInfo, isLogin }

}, { persist: true })

export default useUserInfoStore;